/*
 * Zenlayer.com Inc.
 * Copyright (c) 2014-2020 All Rights Reserved.
 */
package com.shen.core.model;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;

/**
 * @author yangshen
 * @date 2019-09-03 17:03:56
 * @version $ Id: BaseObject.java, v 0.1  yangshen Exp $
 */
public class BaseObject implements Serializable {

    /**
     * 通过JSON重写对象的toString方法
     * @return
     */
    @Override
    public String toString() {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return ObjectUtils.identityToString(this);
    }
}
